package com.wawayaya.bookreader.jni;

import com.wawayaya.util.TLog;
import java.io.File;

/**
 * 拼音转换
 */
public class PinyinConvert {

    private static final String s_strName = "PinYinConvert";

    private static int s_nLoad = -1;
    public static boolean initialize(String strPath)
    {
        if (s_nLoad >= 0)
            return (s_nLoad != 0);
        try
        {
            boolean bExist = false;
            String strFile = "";
            if (strPath != null && strPath.length() > 0)
            {
                strFile = strPath + "/lib" + s_strName + ".so";
                File f = new File(strFile);
                bExist = f.exists();
            }
            if (bExist)
                System.load(strFile);
            else
                System.loadLibrary(s_strName);
            s_nLoad = 1;
        }
        catch(UnsatisfiedLinkError e)
        {
            s_nLoad = 0;
            TLog.log("pinyin : initialize : " + e);
        }
        return (s_nLoad != 0);
    }

	public static native String convert(String inStr);

}
